<%@ page language="java" import="com.newcrm.config.Const,com.newcrm.util.Util,com.newcrm.bean.*,java.util.List,java.util.Map" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
  User user = (User) request.getAttribute("user");
  Map<String, Object> emailSettings = (Map<String, Object>) request.getAttribute("emailSettings");
  List<Map<String, Object>> customerfield = (List<Map<String, Object>>)request.getAttribute("customerfield");

  String host = "";
  int port = 25;
  String username = "";
  String password = "";
  String isSSL = "";
  String emailAddress = "";
  String sign = "";
  if (emailSettings != null) {
    host = (String) emailSettings.get("Host");
    Integer tmp = (Integer) emailSettings.get("Port");
    if (tmp != null) {
      port = tmp.intValue();
    }
    username = (String) emailSettings.get("UserName");
    password = (String) emailSettings.get("UserPwd");
    tmp = (Integer) emailSettings.get("IsSSL");
    if (tmp != null && tmp.intValue() == 1) {
      isSSL = "checked";
    }
    emailAddress = (String) emailSettings.get("EmailAddress");
    sign = (String) emailSettings.get("EmailSign");
  }

  Map<String, Object> voip = (Map<String, Object>) request.getAttribute("voip");
  String voipUserName = "";
  String voipUserPassword = "";
  String voipType = "";
  if (voip != null) {
    voipUserName = (String)voip.get("UserName");
    voipUserPassword = (String)voip.get("UserPwd");
    voipType = (String)voip.get("VOIPType");
  }
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>用户基本信息</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="renderer" content="webkit"/>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <link rel="shortcut icon" href="<%=request.getContextPath()%>/images/qikebao.ico" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/all.css?ver=<%=Const.VERSION%>">
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/datepicker.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap-datetimepicker.min.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/magnific-popup.css">
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery-ui.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.bootstrap-growl.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/moment.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-datepicker.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-datetimepicker.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/daterangepicker.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.magnific-popup.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.cookie.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/popbox.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/common.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/profiles.js?ver=<%=Const.VERSION%>"></script>
  <script>
    var userId = "<%=user.userId%>";
    var customeFieldTypeIds = "<%=user.getShowCustomeFieldTypeIds()%>";
    $(function() {
      $("#identity_sex").val('<%=user.sex%>');
      <%if ("sip".equals(voipType)) {%>
      $("#voip_type_sip").prop("checked", true)
      <%} else {%>
      $("#voip_type_gateway").prop("checked", true)
      <%}%>
      $.each(customeFieldTypeIds.split(','), function(k,item) {
        $("#typeIds_" + item).attr("v", "1").find("i").addClass("fa-check-square-o").removeClass("fa-square-o");
      });
    });
  </script>
</head>
<body class="edit_identity">
  <jsp:include page="topNavi.jsp" flush="true"/>
  <div class="main-page">
    <div class="profile-header">
      <div><img src="<%=request.getContextPath()%>/<%=user.imgPath%>"></div>
      <div class="detail">
        <h1><%=Util.HTMLEncode(user.name)%></h1>
        <p><%=Util.HTMLEncode(user.email)%></p>
      </div>
    </div>
    <div class="clearfix"></div>
    <div class="profile-info-tabs">
      <ul class="nav-tabs" id="tabs">
        <li class="active"><a href="#navi-1">修改信息</a></li>
        <li><a href="#navi-2">SMTP设置</a></li>
        <!--<li><a href="#navi-3">呼叫中心</a></li>-->
        <li><a href="#navi-4">其他设置</a></li>
      </ul>
      <div class="nav-detail">
        <div id="navi-1" class="tab-container body">
          <h1>修改用户基本信息</h1>
          <form action="<%=request.getContextPath()%>/identity/<%=user.userId%>/update" id="identity_form" enctype="multipart/form-data" method="post">
          <table class="setting">
            <tr class="avatar">
              <th><img alt="头像" src="<%=request.getContextPath()%>/<%=user.imgPath%>" /></th>
              <td>
                <div class="change_avatar">
                  <p><label>更改头像</label></p>
                  <p><input id="identity_avatar" name="identity_avatar" size="30" type="file" /></p>
                </div>
              </td>
            </tr>
            <tr>
              <th><label for="identity_name">姓名</label></th>
              <td>
                <div class="validated_field">
                  <p class="field"><input class="normal" id="identity_name" name="identity_name" size="30" tabindex="1" type="text" value="<%=Util.HTMLEncode(user.name)%>" /></p>
                  <p class="error"></p>
                </div>
              </td>
            </tr>
            <tr>
              <th><label for="identity_sex">性别</label></th>
              <td>
                <div class="validated_field">
                  <p class="field">
                    <select id="identity_sex" name="identity_sex" tabindex="3">
                    <option value="1">男</option>
                    <option value="0">女</option>
                    </select>
                  </p>
                </div>
              </td>
            </tr>
            <% if (user.hireDate != null) {%>
            <tr>
              <th><label for="identity_hireDate">入职时间</label></th>
              <td>
                <div class="validated_field">
                  <p class="field"><%=Util.date2Str2(user.hireDate)%></p>
                  <p class="error"></p>
                </div>
              </td>
            </tr>
            <% }%>
            <tr>
              <th><label for="identity_id">证件号</label></th>
              <td>
                <div class="validated_field">
                  <p class="field"><input class="normal" id="identity_id" name="identity_id" size="30" tabindex="5" type="text" value="<%=Util.HTMLEncode(user.idCard)%>" /></p>
                  <p class="error"></p>
                </div>
              </td>
            </tr>
            <tr>
              <th><label for="identity_mobile">手机</label></th>
              <td>
                <div class="validated_field">
                  <p class="field"><input class="normal" id="identity_mobile" name="identity_mobile" size="30" tabindex="6" type="text" value="<%=Util.HTMLEncode(user.mobile)%>" /></p>
                  <p class="error"></p>
                </div>
              </td>
            </tr>
            <tr>
              <th><label for="identity_qq">QQ号</label></th>
              <td>
                <div class="validated_field">
                  <p class="field"><input class="normal" id="identity_qq" name="identity_qq" size="30" tabindex="7" type="text" value="<%=Util.HTMLEncode(user.qq)%>" /></p>
                  <p class="error"></p>
                </div>
              </td>
            </tr>
            <tr>
            <tr>
              <th><label for="identity_email">邮箱</label></th>
              <td>
                <div class="validated_field">
                  <p class="field"><input class="normal" id="identity_email" name="identity_email" size="30" tabindex="8" type="text" value="<%=Util.HTMLEncode(user.email)%>" /></p>
                  <p class="error"></p>
                </div>
              </td>
            </tr>
            <tr>
              <td colspan="2">&nbsp;</td>
            </tr>
            <tbody class="signal_id_credentials">
              <tr class="username_password">
                <th><label for="identity_password">密码</label></th>
                <td>
                  <div class="validated_field">
                    <p class="field"><input class="dummy" id="identity_password" name="identity_password" size="30" tabindex="10" type="password" /></p>
                    <p class="hint">如果不想修改密码，则留空</p>
                    <p class="error"></p>
                  </div>
                </td>
              </tr>
              <tr class="username_password confirm_password">
                <th><label for="identity_password_confirmation">确认密码</label></th>
                <td>
                  <div class="validated_field">
                    <p class="field"><input class="dummy" id="identity_password_confirmation" name="identity_password_confirmation" size="30" tabindex="11" type="password" /></p>
                    <p class="error"></p>
                  </div>
                </td>
              </tr>
            </tbody>
            <tr class="submit">
              <th></th>
              <td>
                <a id="update_profiles_link" class="button blue" href="#"><i class="fa fa-check"></i> 修改个人基本信息</a>&nbsp;&nbsp; <a href="<%=request.getContextPath()%>/users/<%=user.userId%>/edit" class="admin">取消</a>
              </td>
            </tr>
          </table>
          </form>
        </div>
        <div id="navi-2" class="tab-container body">
          <h1>设置发送邮箱的SMTP信息</h1>
          <table class="setting">
            <tr><th width="100"><label for="setting_email">邮箱地址</label></th><td><input class="normal" type="text" name="setting_email" id="setting_email" value="<%=Util.HTMLEncode(emailAddress)%>" ></td></tr>
            <tr><th><label for="setting_smtp">SMTP服务器</label></th><td><input class="normal" type="text" name="setting_smtp" id="setting_smtp" value="<%=Util.HTMLEncode(host)%>" ></td></tr>
            <tr><th><label for="setting_port">SMTP端口</label></th><td><input class="normal" type="text" name="setting_port" id="setting_port" value="<%=port%>"></td></tr>
            <tr><th height="25"><label>安全连接</label></th><td><input type="checkbox" name="setting_ssl" id="setting_ssl" <%=isSSL%>><label for="setting_ssl">此服务器要求安全连接</label></td></tr>
            <tr><th><label for="setting_account">账户名</label></th><td><input class="normal" type="text" name="setting_account" id="setting_account" value="<%=Util.HTMLEncode(username)%>" ></td></tr>
            <tr><th><label for="setting_password">密码</label></th><td><input type="password" class="passwordinput" name="setting_password" id="setting_password" value="<%=Util.HTMLEncode(password)%>" ></td></tr>
            <tr><th><label for="setting_sign">签名</label></th><td><textarea style="width:400px;height:80px;" name="setting_sign" id="setting_sign"><%=Util.HTMLEncode(sign)%></textarea></td></tr>
            <tr><th></th><td><a id="setting_email_link" class="button blue" href="#"><i class="fa fa-check"></i> 修 改 </a> <span class="tips" id="setting_email_tips"></span></td></tr>
          </table>
        </div>
        <!--
        <div id="navi-3" class="tab-container body">
          <h1>设置呼叫中心</h1>
          <p class="tips">同时接入三大运营商落地网关，深度整合企客宝客户管理系统，可实现一键点击呼叫客户，更便捷的与客户沟通。</p>
          <p class="tips">快速构建自己的呼叫中小，提升业务能力，降低通信成本。</p>
          <table class="setting">
            <tr><th width="100"><label for="voip_user">帐号</label></th><td><input class="normal" type="text" name="voip_user" id="voip_user" value="<%=Util.HTMLEncode(voipUserName)%>" ></td></tr>
            <tr><th><label for="voip_pwd">密码</label></th><td><input type="password" class="passwordinput" name="voip_pwd" id="voip_pwd" value="<%=Util.HTMLEncode(voipUserPassword)%>" ></td></tr>
            <tr><th><label>通话方式</label></th><td><div style="padding:5px;height:30px;line-height:30px;"><label for="voip_type_gateway">IP话机:</label><input type="radio" id="voip_type_gateway" name="voip_type" value="gateway"/> <label for="voip_type_sip" style="padding-left:20px;">软电话:</label><input type="radio" id="voip_type_sip" name="voip_type" value="sip"/></td></tr>
            <tr><th></th><td><a id="setting_voip_link" class="button blue" href="#"><i class="fa fa-check"></i> 修 改 </a> <span class="tips" id="setting_voip_tips"></span></td></tr>
          </table>
        </div>
        -->
        <div id="navi-4" class="tab-container body">
          <h1>客户一览显示设置</h1>
          <table class="setting">
            <tr><th width="150"><label for="page_num">每页显示客户数量</label></th><td><input class="normal" type="text" name="page_num" id="page_num" value="<%=user.getCustomerPageSize()%>" ></td></tr>
            <tr><th width="150"><label for="page_num">一览页面显示字段</label></th>
              <td>
                <div class="top10" style="width:80%;" id="typeIds">
                <span id="typeIds_<%=Const.CUSTOMER_EXT_INFO_TYPE_PHONE%>" class="checkbox-button" v="0" typeId="<%=Const.CUSTOMER_EXT_INFO_TYPE_PHONE%>"><i class="fa fa-fw fa-square-o"></i> 电话</span>
                <span id="typeIds_<%=Const.CUSTOMER_EXT_INFO_TYPE_EMAIL%>" class="checkbox-button" v="0" typeId="<%=Const.CUSTOMER_EXT_INFO_TYPE_EMAIL%>"><i class="fa fa-fw fa-square-o"></i> 邮箱</span>
                <span id="typeIds_<%=Const.CUSTOMER_EXT_INFO_TYPE_IM%>" class="checkbox-button" v="0" typeId="<%=Const.CUSTOMER_EXT_INFO_TYPE_IM%>"><i class="fa fa-fw fa-square-o"></i> QQ</span>
                <span id="typeIds_<%=Const.CUSTOMER_EXT_INFO_TYPE_WEBSITE%>" class="checkbox-button" v="0" typeId="<%=Const.CUSTOMER_EXT_INFO_TYPE_WEBSITE%>"><i class="fa fa-fw fa-square-o"></i> 网址</span>
                <span id="typeIds_<%=Const.CUSTOMER_EXT_INFO_TYPE_ADDRESS%>" class="checkbox-button" v="0" typeId="<%=Const.CUSTOMER_EXT_INFO_TYPE_ADDRESS%>"><i class="fa fa-fw fa-square-o"></i> 地址</span>
            <%if ((customerfield != null) && (customerfield.size() > 0)) {
              for (Map<String, Object> filed:customerfield) { %>
                <span id="typeIds_<%=filed.get("CustomerFieldId")%>" class="checkbox-button" v="0" typeId="<%=filed.get("CustomerFieldId")%>"><i class="fa fa-fw fa-square-o"></i> <%=Util.HTMLEncode((String)filed.get("CustomerFieldName"))%></span>
           <%}}%>
                </div>
              </td></tr>
            <tr><th></th><td><a id="setting_basic_link" class="button blue" href="#"><i class="fa fa-check"></i> 修 改 </a></td></tr>
          </table>
        </div>
      </div>
    </div>
  </div>
</body>
</html>